<template>
  <view class="container">
    <!-- Your content here -->
    <u-picker
      @cancel="close"
      @close="close"
      closeOnClickOverlay
      title="选择接单群"
      :show="show"
      :columns="columns"
      keyName="name"
      @confirm="change"
    ></u-picker>
  </view>
</template>

<script>
import api from "@/api"
export default {
  props: {
    show: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      // Your data here
      columns: [],
    }
  },
  watch: {
    show: {
      handler(v) {
        if (v) {
          this.loadData()
        }
      },
    },
  },
  onLoad() {
    // Page load
  },
  methods: {
    // Your methods here
    loadData() {
      api.user.sell_group().then((res) => {
        if (res.code == 200) {
          this.columns = [res.data]
        }
      })
    },
    change(e) {
      console.log(e)
      this.$emit("confirm", e.value[0])
    },
    close() {
      this.$emit("close")
    },
  },
}
</script>

<style lang="scss" scoped>
.container {
  /* Your styles here */
}
</style>
